#pragma once
#include <memory>
#include <string>
#include <list>
#include "../../utils/common_ptr.h"

class SymbolTable
{
public:
  class Entry
  {
  public:
    long hash;
    int len;
    std::wstring value;

    Entry(long hash, int len, std::wstring value);
  };
  // static Charset UTF8 = Charset.forName("UTF-8");
  static string_ptr UTF8;
  static BOOL_ptr JVM_16;

  string_ptr version;

  static SymbolTable_ptr global;

  std::shared_ptr<std::list<std::shared_ptr<SymbolTable::Entry>>> entries;
  int indexMask;

  SymbolTable(int tableSize);

  std::wstring addSymbol(std::wstring buffer, int offset, int len, long hash);

  std::wstring addSymbol(wchar_t *buffer, int offset, int len, long hash);

  std::wstring addSymbol(std::wstring symbol, long hash);

  std::wstring findSymbol(long hash);

  static std::wstring subString(std::wstring src, int offset, int len);

  static std::wstring subString(wchar_t *bytes, int from, int len);
};
